package com.hakim.wfb.common.serial;

import com.hakim.wfb.common.util.DateUtils;

/**
 * Created by lenovo on 2017/7/2.
 */
public class SerialNoGenerator {
    //public static final String INVESTMENT_ORDER_PREFIX = "IO";//投资
    //public static final String TRANSFER_ORDER_PREFIX = "TO";//转账
    //public static final String RECHARGE_ORDER_PREFIX = "RO";//充值
    //public static final String WITHDRAWAL_ORDER_PREFIX = "WO";//提现
    //public static final String PROFIT_ORDER_PREFIX = "PO";//分红
    //public static final String SHOPPING_ORDER_PREFIX = "SO";//商城消费

    /*
    public static String getSerailNo(String tp, String tel) {
        String datStr = DateUtils.getUserDate("yyyyMMddHHmmss");
        StringBuffer telBuff = new StringBuffer();
        if (null == tel || "" == tel) {
            telBuff = new StringBuffer("00000000000");
        } else {
            for (int i = 0; i < 11 - tel.length(); i++) {
                telBuff.insert(0, '0');
            }
        }
        String ranStr = "";
        int ran = (int) (Math.random() * Math.pow(10, 5));
        String f = "%05d";
        ranStr = String.format(f, ran);
        return tp + datStr + telBuff.toString() + ranStr;
    }
    */
    public static String getSerailNo(String tp, String tel) {
        String datStr = DateUtils.getUserDate("yyyyMMddHHmmss");
        StringBuffer telBuff = new StringBuffer();
        /*
        for (int i = 0; i < 11 - tel.length(); i++) {
            telBuff.insert(0, '0');
        }*/
        String ranStr = "";
        int ran = (int) (Math.random() * Math.pow(10, 5));
        String f = "%05d";
        ranStr = String.format(f, ran);
        return tp + datStr + telBuff.toString() + ranStr;
    }

    /**
     * 订单流水号
     *
     * @param tel
     * @return
     */
    public static String getGoodsOrderNo(String tel) {
        return getSerailNo("GO", tel);
    }

    /**
     * 用户激活流水号
     *
     * @param tel
     * @return
     */
    public static String getActivateOrderNo(String tel) {
        return getSerailNo("AO", tel);
    }


    /**
     * 投资流水号
     *
     * @param tel
     * @return
     */
    public static String getInvestmentOrderNo(String tel) {
        return getSerailNo("IO", tel);
    }

    /**
     * 分红流水号
     *
     * @param tel
     * @return
     */
    public static String getProfitOrderNo(String tel) {
        return getSerailNo("PO", tel);
    }

    /**
     * 提现流水号
     *
     * @param tel
     * @return
     */
    public static String getWithdrawalOrderNo(String tel) {
        return getSerailNo("WO", tel);
    }

    /**
     * 商城消费流水号
     *
     * @param tel
     * @return
     */
    public static String getShoppingOrderNo(String tel) {
        return getSerailNo("SO", tel);
    }

    /**
     * 转账流水号
     *
     * @param tel
     * @return
     */
    public static String getTransPointOrderNo(String tel) {
        return getSerailNo("TO", tel);
    }

    /**
     * 充值
     *
     * @param tel
     * @return
     */
    public static String getRechargeOrderNo(String tel) {
        return getSerailNo("RO", tel);
    }

    /**
     * 兑换
     *
     * @param tel
     * @return
     */
    public static String getExchargeOrderNo(String tel) {
        return getSerailNo("EX", tel);
    }

    public static void main(String[] args) {
        System.out.println("----------------");
        for (int i = 0; i < 10; i++) {
            System.out.println(getSerailNo("se", ""));
        }
    }
}
